#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
const LL mod=1e9+7;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL ksm(LL a,LL k){LL res=1;while(k>0){if(k&1) res=res*a%mod;k>>=1;a=a*a%mod;}return res%mod;}
map<LL,LL>map1[maxn];
multiset<LL>s[maxn];
LL a[maxn],gcd=1;
LL n,q;
void add(LL k,LL num,LL tmp){
    if(map1[k].count(num)){
        if(s[num].size()==n){
            LL temp=ksm(num,*s[num].begin())%mod;
            gcd=(gcd%mod*ksm(temp,mod-2)%mod)%mod;
        }
        s[num].erase(s[num].find(map1[k][num]));
        map1[k][num]+=tmp;
        s[num].insert(map1[k][num]);
        if(s[num].size()==n){
            gcd=(gcd%mod*ksm(num,*s[num].begin())%mod)%mod;
        }
    }
    else{
        map1[k][num]=tmp;
        s[num].insert(map1[k][num]);
        if(s[num].size()==n) gcd=(gcd%mod*ksm(num,*s[num].begin())%mod)%mod;
    }
}
void dive(LL k,LL num){
    for(int i=2;i<=sqrt(num);i++){
        if(num%i==0){
            LL tmp=0;
            while(num%i==0){
                num/=i;
                tmp++;
            }
            add(k,i,tmp);
        }
    }
    if(num>1) add(k,num,1);
}
int main(void)
{
  n=read();q=read();
  for(int i=1;i<=n;i++){
     a[i]=read();
     dive(i,a[i]);
  }
  while(q--){
     LL id,x;id=read();x=read();
     dive(id,x);
     printf("%lld\n",gcd);
  }
return 0;
}
